package tool.dataType;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MiddleCommonUtils {

	public static String getMatch(String str,String regex,Integer no){
		String retStr = null;
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(str);
		if(no != null && no >0){
			retStr = matcher.find()?matcher.group(no):"";
		}else{
			retStr = matcher.find()?matcher.group():"";
		}
		return retStr;
	}
	public static String getName(String title){
		return getMatch(title,"(- )([^\\[]*)\\[(\\d+)",2);
	}
	
	public static String getId(String title){
		return getMatch(title,"(- )([^\\[]*)\\[(\\d+)\\]",3);
	}

}
